<?php

class ControllerCommonHome extends Controller {

	public function index() {

		$this->document->setTitle ( $this->config->get ( 'config_title' ) );

		$this->document->setDescription ( $this->config->get ( 'config_meta_description' ) );

		

		$this->data ['heading_title'] = $this->config->get ( 'config_title' );

		

		// *************取最新，特价，推荐商品************

		$this->load->model ( 'catalog/product' );

		$this->load->model ( 'tool/image' );

		$last_products = $this->model_catalog_product->getLatestProducts ( 10 );

		$this->data ['last_products'] = $this->model_tool_image->resizeProductImage ( $last_products, 'image', 128, 88 );

		$on_sales = $this->model_catalog_product->getOnSaleProducts ( 4 );

		$this->data ['on_sales'] = $this->model_tool_image->resizeProductImage ( $on_sales, 'image', 121, 117 );

		$recs = $this->model_catalog_product->getRecProcucts ( 4 );

		$this->data ['recs'] = $this->model_tool_image->resizeProductImage ( $recs, 'image', 121, 117 );

		$this->data['logged'] = $this->customer->isLogged();

		

		/**

		 * *************获取配置信息*****************

		 */

		$this->load->model ( 'web/index' );

		$this->load->model ( 'tool/image' );

		$pics=$this->model_web_index->getSetting ( 4 );

		if(isset($pics)&&is_array($pics)){

			foreach ($pics as $k=>$v){

				$pics[$k]['pic']=$this->model_tool_image->resize($v['content'],550,240 );

			}

		}

		$this->data ['focus_pics'] = $pics;

		

		if (file_exists ( DIR_TEMPLATE . $this->config->get ( 'config_template' ) . '/template/common/home.tpl' )) {

			$this->template = $this->config->get ( 'config_template' ) . '/template/common/home.tpl';

		} else {

			$this->template = 'default/template/common/home.tpl';

		}

		

		$this->children = array (

				'common/column_left',

				'common/column_right',

				'common/content_top',

				'common/content_bottom',

				'common/footer',

				'common/header' 

		);

		

		$this->response->setOutput ( $this->render () );

	}

}

?>